package cn.iocoder.yudao.module.worker.dal.mysql.goods;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.worker.controller.app.goods.vo.AppWorkerGoodsPageReqVO;
import cn.iocoder.yudao.module.worker.dal.dataobject.goods.WorkerGoodsDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.worker.controller.admin.goods.vo.*;

/**
 * 商品管理 Mapper
 *
 * @author Jerry
 */
@Mapper
public interface WorkerGoodsMapper extends BaseMapperX<WorkerGoodsDO> {

    default PageResult<WorkerGoodsDO> selectPage(WorkerGoodsPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<WorkerGoodsDO>()
                .likeIfPresent(WorkerGoodsDO::getName, reqVO.getName())
                .eqIfPresent(WorkerGoodsDO::getCategoryId, reqVO.getCategoryId())
                .eqIfPresent(WorkerGoodsDO::getCategoryParentId, reqVO.getCategoryParentId())
                .eqIfPresent(WorkerGoodsDO::getWeight, reqVO.getWeight())
                .eqIfPresent(WorkerGoodsDO::getHour, reqVO.getHour())
                .eqIfPresent(WorkerGoodsDO::getPrice, reqVO.getPrice())
                .betweenIfPresent(WorkerGoodsDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(WorkerGoodsDO::getId));
    }

    default List<WorkerGoodsDO> selectList(WorkerGoodsPageReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<WorkerGoodsDO>()
                .likeIfPresent(WorkerGoodsDO::getName, reqVO.getName())
                .eqIfPresent(WorkerGoodsDO::getCategoryId, reqVO.getCategoryId())
                .eqIfPresent(WorkerGoodsDO::getCategoryParentId, reqVO.getCategoryParentId())
                .eqIfPresent(WorkerGoodsDO::getWeight, reqVO.getWeight())
                .eqIfPresent(WorkerGoodsDO::getHour, reqVO.getHour())
                .eqIfPresent(WorkerGoodsDO::getPrice, reqVO.getPrice())
                .betweenIfPresent(WorkerGoodsDO::getCreateTime, reqVO.getCreateTime())
                .inIfPresent(WorkerGoodsDO::getId, reqVO.getGoodsIdList())
                .orderByDesc(WorkerGoodsDO::getWeight));
    }

    default PageResult<WorkerGoodsDO> selectPage(AppWorkerGoodsPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<WorkerGoodsDO>()
                .likeIfPresent(WorkerGoodsDO::getName, reqVO.getName())
                .eqIfPresent(WorkerGoodsDO::getCategoryId, reqVO.getCategoryId())
                .eqIfPresent(WorkerGoodsDO::getCategoryParentId, reqVO.getCategoryParentId())
                .eqIfPresent(WorkerGoodsDO::getWeight, reqVO.getWeight())
                .eqIfPresent(WorkerGoodsDO::getHour, reqVO.getHour())
                .eqIfPresent(WorkerGoodsDO::getPrice, reqVO.getPrice())
                .betweenIfPresent(WorkerGoodsDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(WorkerGoodsDO::getId));
    }

    default List<WorkerGoodsDO> selectList(AppWorkerGoodsPageReqVO reqVO){
        return selectList(new LambdaQueryWrapperX<WorkerGoodsDO>()
                .likeIfPresent(WorkerGoodsDO::getName, reqVO.getName())
                .eqIfPresent(WorkerGoodsDO::getCategoryId, reqVO.getCategoryId())
                .eqIfPresent(WorkerGoodsDO::getCategoryParentId, reqVO.getCategoryParentId())
                .eqIfPresent(WorkerGoodsDO::getWeight, reqVO.getWeight())
                .eqIfPresent(WorkerGoodsDO::getHour, reqVO.getHour())
                .eqIfPresent(WorkerGoodsDO::getPrice, reqVO.getPrice())
                .betweenIfPresent(WorkerGoodsDO::getCreateTime, reqVO.getCreateTime())
                .inIfPresent(WorkerGoodsDO::getId, reqVO.getGoodsIdList())
                .eq(WorkerGoodsDO::getStatus, true)
                .orderByDesc(WorkerGoodsDO::getWeight));
    }
}